package com.general.client.widgets.yesnomodal;

import com.general.client.action.ActionHandler;
import com.general.client.basewidget.BaseWidget;
import com.general.client.bundle.CommonBundle;
import com.general.client.widgets.button.green.GreenButton;
import com.general.client.widgets.button.red.RedButton;
import com.general.client.widgets.modalwindow.ModalWindow;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.Widget;

public class YesNoModal extends BaseWidget implements
		YesNoModalPresenter.Display {
	@UiField
	ModalWindow modal;

	@UiField
	Label headerLabel;

	@UiField
	RedButton noButton;

	@UiField
	GreenButton yesButton;

	@UiField
	CommonBundle common;

	private static HistoryModalUiBinder uiBinder = GWT
			.create(HistoryModalUiBinder.class);

	interface HistoryModalUiBinder extends UiBinder<Widget, YesNoModal> {
	}

	public YesNoModal() {
		initWidget(uiBinder.createAndBindUi(this));
		yesButton.getText().setText("Yes");
		noButton.getText().setText("No");
	}

	@Override
	public void show(boolean show) {
		modal.show(show);
	}

	@Override
	public void setText(String name) {
		headerLabel.setText(name);
	}

	@Override
	public HandlerRegistration addYesActionHandler(ActionHandler handler) {
		return yesButton.addActionHandler(handler);
	}

	@Override
	public HandlerRegistration addNoActionHandler(ActionHandler handler) {
		return noButton.addActionHandler(handler);
	}
}
